<!--首页 测试者登录页面-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <title>登录界面</title>
    <link href="css/default.css" rel="stylesheet" type="text/css" />
    <!--必要样式-->
    <link href="css/styles.css" rel="stylesheet" type="text/css" />
    <link href="css/demo.css" rel="stylesheet" type="text/css" />
    <link href="css/loaders.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class='login'>
    <div class='login_title'>
        <span>性格测试系统</span>
    </div>

    <form class="layui-form" id="loginForm" method="post" >
        <div class='login_fields'>
            <div class='login_fields__user'>
                <div class='icon'>
                    <img alt="" src='img/user_icon_copy.png'>
                </div>
                <input name="name" placeholder='用户名' lay-verify="required" maxlength="16" type='text' autocomplete="off" />
                <div class='validation'>
                    <img alt="" src='img/tick.png'>
                </div>
            </div>
            <div class='login_fields__password'>
                <div class='icon'>
                    <img alt="" src='img/lock_icon_copy.png'>
                </div>
                <input name="phone" placeholder='手机号' lay-verify="required|phone" maxlength="16" type='text' autocomplete="off">
                <div class='validation'>
                    <img alt="" src='img/tick.png'>
                </div>
            </div>
            <div class='login_fields__submit'>
                <input type='button' value='登录' lay-submit lay-filter="loginFormFilter">
            </div>
        </div>
    </form>

    <div class='success'>
    </div>
    <div class='disclaimer'>
        <p>欢迎登陆性格测试系统，登录即代表您同意注册</p>
    </div>
</div>
<div class='authent'>
    <div class="loader" style="height: 44px;width: 44px;margin-left: 28px;">
        <div class="loader-inner ball-clip-rotate-multiple">
            <div></div>
            <div></div>
            <div></div>
        </div>
    </div>
    <p>认证中...</p>
</div>
<div class="OverWindows"></div>
<link href="layui/css/layui.css" rel="stylesheet" type="text/css" />
<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
<script type="text/javascript" src='js/stopExecutionOnTimeout.js?t=1'></script>
<script src="layui/layui.js" type="text/javascript"></script>
<script src="js/Particleground.js" type="text/javascript"></script>
<script src="Js/Treatment.js" type="text/javascript"></script>
<script src="js/jquery.mockjax.js" type="text/javascript"></script>
</body>
<script type="text/javascript">

    layui.use(['table','form','laydate','jquery',"layer"], function(){
        var $=layui.jquery;
        var form = layui.form;
        var layer = layui.layer;
        //粒子背景特效
        //表单提交监听
        form.on('submit(loginFormFilter)', function(data) {
            //检查是否已经注册过
            $.ajax({
                url: "tester/selectByNameAndPhone",
                data: JSON.stringify(data.field),
                dataType:"json",
                contentType:"application/json",
                type: "post",
                success: function (data) {
                    if (data.code === 0) {
                        //提示操作成功 即插入成功，跳转到测试问题页面
                        layer.msg(data.msg, {icon: 6});
                        //跳转界面
                        window.location.href = "toTestQuestion?uid=" + data.data.id;

                    } else {
                        // 操作失败
                        // 1.用户名错误
                        // 2. 已经登陆过但没完成测试  重新测试
                        // 3.已完成测试 显示测试结果
                        if (data.msg === "用户名错误") {
                            alert("用户名错误");
                        }else if(data.msg === "重新测试"){
                            var testerId = "toTestQuestion?uid=" + data.data.id
                            console.log(testerId)
                            window.location.href = "toTestQuestion?uid=" + data.data.id;
                        }else{  // 查看结果
                            window.location.href = "toShowResult?uid=" + data.data.id;
                        }

                    }
                }

            });

        })
        $('body').particleground({
            dotColor: '#E8DFE8',
            lineColor: '#133b88'
        });

    })

</script>
</html>